import 'package:json_annotation/json_annotation.dart';

part 'base_rows_list_model.g.dart';
/// 列表数据模型（带分页）
@JsonSerializable(genericArgumentFactories: true)
class BaseRowsListModel<T> {
  List<T>? rows;
  int? total;
  int? size;
  int? current;
  int? pages;

  BaseRowsListModel({this.rows, this.total});

  static Map<dynamic, dynamic>? _parseMap(Object? json) {
    if (json == null) return null;
    if (json is Map<dynamic, dynamic>) return json;
    if (json is Map) return Map<dynamic, dynamic>.from(json);
    return null;
  }

  // 从JSON 创建实例
  factory BaseRowsListModel.fromJson(Map<String, dynamic> json, T Function(Object?) fromJsonT) =>
      _$BaseRowsListModelFromJson(json, fromJsonT);

  Map<String, dynamic> toJson(Object Function(T value) toJsonT) => _$BaseRowsListModelToJson(this, toJsonT);
}
